<template>
  <div class="list" ref="wrapper">
    <div>
    <div class="area">
        <div class="title border-topbottom">当前城市</div>
        <div class="button-list">
            <div class="button-wraper">
                <div class="button">北京</div>
            </div>
        </div>
    </div>
    <div class="area">
        <div class="title border-topbottom">热门城市</div>
        <div class="button-list">
             <div class="button-wraper" v-for="item of hotcities" :key="item.id">
                    <div class="button">{{item.name}}</div>
            </div>
        </div>
        
    </div>
    <div class="area" v-for="(items,key) of cities" :key="key" :ref="key">
        <div class="title border-topbottom" >{{key}}</div>
        <div class="item-list">
            <div class="item border-bottom"  v-for="item of items" :key="item.id">{{item.name}}</div>
        </div>
    </div>
   
    </div>
  </div>
</template>

<script>
import Bscroll from 'better-scroll'

export default {
  name: "CityList",
  props:{
      cities:Object,
      hotcities:Array,
      al:String
  },
  data () {
      return {
          scroll:{}
      }
  },
  mounted () {
      this.scroll=new Bscroll(this.$refs.wrapper)
  },
  watch:{
      al () {
           if (this.al){
              const k=this.$refs[this.al][0]
              this.scroll.scrollToElement(k)
           }
      }
  }
};
</script>

<style lang="stylus" scoped>
@import '~styles/varibles.styl';

.list {
    overflow: hidden;
    position: absolute;
    top: 3.8rem;
    right: 0;
    bottom: 0;
    left: 0;

    .border-topbottom {
        &:before {
            border-color: #777;
        }

        &:after {
            border-color: #777;
        }
    }

    .title {
        background: #eee;
        line-height: 1.86rem;
        padding-left: 0.2rem;
        color: #666;
        font-size: 0.26rem;
    }

    .button-list {
        overflow: hidden;
        padding: 0.1rem 0.8rem 0.1rem 0.1rem;

        .button-wraper {
            float: left;
            width: 33.33%;

            .button {
                margin: 0.1rem;
                text-align: center;
                border: 0.01rem solid #ccc;
                padding: 0.1rem 0;
                font-size: 0.26rem;
            }
        }
    }

    .item-list {
        .item {
            padding-left: 0.2rem;
            color: #666;
            line-height: 2rem;
            height: 2rem;
            font-size: 0.26rem;
        }
    }
}
</style>
